package com.weilive.core.netty.client;

import com.weilive.core.protocol.json.JsonPacket;
import com.weilive.core.utils.HttpUtils;

public class NettyHttpClient {

	public final String url;
	
	public NettyHttpClient(String url) {
		this.url = url;
	}
	
	public JsonPacket doPost(JsonPacket request) {
		try {
			return JsonPacket.decode(HttpUtils.HttpPostGo(url, request.encode()));
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public JsonPacket doGet(String url) {
		try {
			return JsonPacket.decode(HttpUtils.HttpGetGo(this.url + url));
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
